package com.czd.support.util;

import org.apache.commons.lang3.StringUtils;

/**
 * Created with IntelliJ IDEA.
 * Author: Jerry.hu
 * Create: Jerry.hu (14-8-27 20:16)
 * Description:
 * To change this template use File | Settings | File Templates.
 */
public class StringReplaceUtils {
	public static String replaceStrByChar(String oldStr,String chart,int begin,int end){
		/*if(StringUtils.isBlank(oldStr)){
			return null;
		}
//		String o = oldStr.re
		String searchStr = "?";
		int index = oldStr.indexOf(searchStr);
		int count = 1;
		while (count != begin) {
			index = str.indexOf(searchStr, index + 1);
			count++;
		}


		return oldStr.substring(0, index) + rstr + str.substring(index + 1);*/
		return "";
	}

	public  static String stuffPhone(String phone)
	{
		return phone.substring(0,2)+"*******"+phone.substring(9);
	}

	public static String stuffMail(String mail){
		if(StringUtils.isBlank(mail)){
			return null;
		}else{
			int lastIndex = mail.lastIndexOf("@");
			if(lastIndex >= 2){
				return 	mail.substring(0,2)+"*******"+mail.substring(lastIndex);
			}
			return "*******"+mail.substring(lastIndex);
		}
	}
	public static void main(String[] args) {
		System.out.println(stuffPhone("18621910807"));
		System.out.println(stuffMail("f@163.com"));
	}


}
